package com.magicsoft.share.adapter.share;

import android.graphics.Paint;
import android.support.annotation.LayoutRes;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.magicsoft.share.R;
import com.magicsoft.share.bean.my.UserList;

/**
 * @author lyf
 * @date 2017/10/27/027
 * 搜索结果 ，用户列表
 */

public class UserAdapter extends BaseQuickAdapter<UserList.ListBean, BaseViewHolder> {

    private final int type;

    public UserAdapter(@LayoutRes int layoutResId, int type) {
        super(layoutResId);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, UserList.ListBean item) {
        helper.addOnClickListener(R.id.btn).addOnClickListener(R.id.iv_head);
        ImageView iv_head = helper.getView(R.id.iv_head);
        TextView tv_name = helper.getView(R.id.tv_name);
        Button btn = helper.getView(R.id.btn);

        Glide.with(mContext).load(item.getHeadimg()).into(iv_head);
        tv_name.setText(item.getNickname());
        tv_name.getPaint().setFlags(Paint.FAKE_BOLD_TEXT_FLAG);
        helper.setText(R.id.tv_signature, item.getPersonalizedSignature());
        if (type != 1) {
            //2表示我的粉丝界面  1表示我的关注界面
            if (item.isFollowStatus()) {
                btn.setText("取消关注");
                btn.setBackgroundResource(R.drawable.bg_shape_gray);

            } else {
                btn.setText("关注");
                btn.setBackgroundResource(R.drawable.bg_shape_black);
            }
        }


    }
}
